from django.db import models
from apps.common.base.models import BaseModel
from apps.system.lessee.models import Lessee

class Rank(BaseModel):

    lessee = models.ForeignKey(Lessee, related_name="lessee_rank", verbose_name='租户', on_delete=models.SET_NULL,
                               null=True, blank=True, db_constraint=False)
    name=models.CharField("名称", max_length=200, blank=True, null=True)
    grade=models.IntegerField("级别", default=0)

    # 升级条件
    upMoney = models.DecimalField("升级金额", max_digits=10, decimal_places=2, default=0.00)
    verticalPeopleNumber = models.IntegerField("直推人数", default=0)
    verticalOrderNumber = models.IntegerField("直推单数", default=0)
    verticalPerformance = models.DecimalField("直推业绩", max_digits=10, decimal_places=2, default=0.00)
    teamPeopleNumber = models.IntegerField("团队人数", default=0)
    teamOrderNumber = models.IntegerField("团队单数", default=0)
    teamPerformance = models.DecimalField("团队业绩", max_digits=10, decimal_places=2, default=0.00)
    # 分成比例
    verticalAward = models.DecimalField("直推奖", max_digits=10, decimal_places=2, default=0.00)
    verticalAwardRate = models.DecimalField("直推奖比例", max_digits=10, decimal_places=2, default=0.00)
    gradeAward = models.DecimalField("见点奖金额", max_digits=10, decimal_places=2, default=0.00)
    gradeAwardRate = models.DecimalField("见点奖比例", max_digits=10, decimal_places=2, default=0.00)
    isRetrospect = models.BooleanField('是否追溯见点奖', default=1)
    isLevelAward = models.BooleanField('是否开启平级奖励', default=0)

    class Meta:
        verbose_name = 'Rank'
        verbose_name_plural = verbose_name